package com.lhz.model.response;


import lombok.Data;

/**
 * Date on 2019/4/15 15:16
 */
@Data
public class ResponseObject {

    private Boolean success;

    private String message;

    private int code;

    private Object data;

    private String service;

    public ResponseObject setService(String service) {
        this.service = service;
        return this;
    }

    public static ResponseObject successPost(int num) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setCode(200);
        responseObject.setMessage("成功添加" + num + "数据");
        return responseObject;
    }

    public static ResponseObject successUpdate(int num) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setCode(200);
        responseObject.setMessage("成功修改" + num + "数据");
        return responseObject;
    }

    public static ResponseObject successDel(int num) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setCode(200);
        responseObject.setMessage("成功删除" + num + "数据");
        return responseObject;
    }


    public static ResponseObject success(Object object) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setData(object);
        responseObject.setCode(200);
        responseObject.setMessage("操作成功");
        return responseObject;
    }

    public static ResponseObject success(String msg) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setCode(200);
        responseObject.setMessage(msg);
        return responseObject;
    }

    public static ResponseObject success() {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setCode(200);
        responseObject.setMessage("操作成功");
        return responseObject;
    }

    public static ResponseObject success(Object object, String msg) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(true);
        responseObject.setData(object);
        responseObject.setCode(200);
        return responseObject;
    }

    public static ResponseObject fail(String msg) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(false);
        responseObject.setCode(500);
        responseObject.setMessage(msg);
        return responseObject;
    }

    public static ResponseObject fail() {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(false);
        responseObject.setCode(500);
        responseObject.setMessage("操作失败");
        return responseObject;
    }

    public static ResponseObject fail(String msg, int code) {
        ResponseObject responseObject = new ResponseObject();
        responseObject.setSuccess(false);
        responseObject.setCode(code);
        responseObject.setMessage(msg);
        return responseObject;
    }
}